package com.kube.design.prototypepattern;

import java.io.*;

/**
 * @author q.zhangr
 * @version 1.0.0
 * @date 2020/7/22
 */
public class WeeklyLog2 implements Serializable {

    private Attachment2 attachment;
    private String date;
    private String name;
    private String content;

    public Attachment2 getAttachment() {
        return attachment;
    }

    public void setAttachment(Attachment2 attachment) {
        this.attachment = attachment;
    }

    public String getDate() {
        return date;
    }

    public void setDate(String date) {
        this.date = date;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    /**
     * 通过序列化进行深克隆
     *
     * @return
     * @throws Exception
     */
    public WeeklyLog2 deepclone() throws Exception {
        //将对象写入流中,
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(bao);
        oos.writeObject(this);
        //将对象取出来
        ByteArrayInputStream bi = new ByteArrayInputStream(bao.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(bi);
        return (WeeklyLog2) ois.readObject();


    }


}
